package com.socket.batch.transmit;


import com.socket.entity.GpsRecord;
import com.socket.service.GpsBatchService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.List;

/**
 * 批量操作数据的入口
 * Created by kaddddd on 2017/7/6 0006.
 */
public class BatchTransmitter extends AbstractTransmitter{
    private static final Logger logger = LoggerFactory.getLogger(BatchTransmitter.class);
    @Override
    public void transition(List<GpsRecord> list) {
        ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");

        GpsBatchService gpsBatchService = (GpsBatchService)ctx.getBean("gpsBatchService");
        try {
            gpsBatchService.batchInsertGpsRecord(list);
            logger.info("批量插入数据完成!");
            //System.out.println("批量插入数据完成!");
        }catch (Exception e){
            e.printStackTrace();
            logger.error("批量插入数据失败!");
        }

    }

}

